package com.igeekhome.ccs.biz.impl;

import com.igeekhome.ccs.biz.IAnnouncementBiz;
import com.igeekhome.ccs.entity.Announcement;
import com.igeekhome.ccs.entity.AnnouncementJoinCs;
import com.igeekhome.ccs.mapper.AnnouncementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class AnnouncementBizImpl implements IAnnouncementBiz {

    @Autowired
    private AnnouncementMapper mapper;
    /**
     * 添加一个公告
     * @param ad
     * @return
     */
    @Override
    public int save(Announcement ad) {
        int a = mapper.save(ad);
        return a;
    }

    /**
     * 更新公告
     */
    @Override
    public int update(Announcement ad) {
        int a = mapper.update(ad);
        return a;
    }

    @Override
    public List<AnnouncementJoinCs> getAll() {
        return mapper.getAll();
    }

    /**
     * 根据id删除一个公告
     */
    @Override
    public int delete(int id) {
        int a = mapper.delete(id);
        return a;
    }

    /**
     * 根据id批量删除公告
     */
    @Override
    public int deleteBatch(List<Integer> ids) {
        int a = mapper.deleteBatch(ids);
        return a;
    }

    /**
     * 根据公告标题查询
     */
    @Override
    public List<AnnouncementJoinCs> queryByTitle(String title) {
        List<AnnouncementJoinCs> list = mapper.queryByTitle(title);
        return list;
    }

    /**
     * 根据起止时间查询
     */
    @Override
    public List<AnnouncementJoinCs> queryByTime(Date start, Date end) {
        List<AnnouncementJoinCs> list = mapper.queryByTime(start,end);
        return list;
    }

    /**
     * 根据id查询单个公告
     */
    @Override
    public Announcement queryById(int id) {
        return mapper.queryById(id);
    }
}
